<template>
  {{ d.num.toFixed(0) }}
</template>

<script setup>
import { ref, watch } from "vue";
import gsap from "gsap";

const props = defineProps({
  value: 0,
});
const d = ref({
  num: 0,
});

function animatedToValue() {
  gsap.to(d.value, {
    duration: 0.5,
    num: props.value,
  });
}

animatedToValue();

watch(
  () => props.value,
  () => animatedToValue()
);
</script>
